// const arr = ['I', 'have', 'a', 'book', 'good']

// const fn = (str) => {
//   const _arr = str.split(' ')
//   const result = _arr.every(item => {
//     return arr.includes(item)
//   })
//   return result
// }
// console.log(fn('I have a book good'))
// console.log(fn('I have two book good'))

// const reverseList = head => {
//   // 到了尾节点，则返回尾节点
//   if (head == null || head.next == null) {
//     return head
//   } else {
//     let newhead = reverseList(head.next)
//     // 将当前节点的一下节点的 next 指向，指向为当前节点
//     head.next.next = head
//     // 暂时清空当前节点的 next 指向
//     head.next = null
//     return newhead
//   }
// }

const reverseList = head => {
  let prev = null,
      current = head,
      temp
  
  while (head) {
    temp = current.next 
    current.next = prev
    current = temp
  }
  return prev
}


Function.prototype.bindSelf = (context, ...args) => {
  return (...rest) => this.call(context, ...args, ...rest)
}

Function.prototype.bindSelf = function () {
  const args = [...arguments]
  const t = args.shift()
  const self = this

  return function () {
    return self.apply(t, args)
  }
}

const numFormat = number => {
  return number.toString().replace(/\d+/, n => {
    return n.replace(/(\d)(?=(\d{3})+$)/g, ($1) => {
      return $1 + ','
    })
  })
}

